package czk.concrent.reentrantLock;

import java.util.concurrent.locks.ReentrantLock;

/**
 * @Author:ChenZhangKun
 * @Date: 2020/5/31 16:12
 */
// reentrantLock的可重人性
public class Test1 {
    static ReentrantLock lock=new ReentrantLock();
    public static void main(String[] args) {
        // 这个是不可打断的
        lock.lock();
        try {
            System.out.println("main 进入");
            method1();
        }finally {
            lock.unlock();
        }
    }
    public static void method1(){
        lock.lock();
        try {
            System.out.println("method1 进入");
            method2();
        }finally {
            lock.unlock();
        }
    }
    public static void method2(){
        lock.lock();
        try {
            System.out.println("method2 进入");
        }finally {
            lock.unlock();
        }
    }
}
